const app = getApp();
const { AskPage } = app._require('common/index');
const formMixin = app._require("mixins/form.mixin.js").default;
import { taskMixin } from "./mixin.js";
AskPage({
    /**
     * 页面的初始数据
     */
    name: "task",
    mixins: [formMixin, taskMixin],
    data: {
        searchValue: "",
        sortValue: "",
        sortList: [
            { label: "正序排序", value: "1" },
            { label: "倒序排序", value: "2" },
        ],
        sortTypeValue: "",
        sortTypeList: [
            { label: "发布时间", value: "create" },
            { label: "截至日期", value: "end" },
            { label: "任务名称", value: "name" },
        ],
        taskStateValue: "COMPLETE",
        endTime: "",
        createTime: "",
    },
    onLoad: function (options) {
        console.log("appInfo", app);
   
    },
    onShow() {
        if (typeof this.getTabBar === "function" && this.getTabBar()) {
            this.getTabBar().setData({
                active: "/" + this.route,
            });
        }
        this.setData({
            user: app.user,
        });
        // let _change = this.checkUserChange();
        // if (_change) {
        //     this.loginSuccess();
        // }
    },
    handleDropClick(e) {
        let { key } = e.currentTarget.dataset;
        let { value: item } = e.detail;
        // this.selectComponent("#sortDrop").toggle();
        this.setData({
            [key]: item.value || "",
        });
    },
    handleTypeDropClick(e) {
        let { key } = e.currentTarget.dataset;
        let { value: item } = e.detail;
        // this.selectComponent("#typeDrop").toggle();
        let _setValue = item.value || "";
        // if (_setValue === this.data[key]) {
        //     _setValue = "";
        // }
        this.setData({
            [key]: _setValue,
        });
    },
    onDateSure(e) {
        let { key } = e.currentTarget.dataset;
        let { value } = e.detail;
        // this.selectComponent("#typeDrop").toggle();
        this.setData({
            [key]: value || "",
        });
    },
    onChange() {
        let { key } = e.currentTarget.dataset;

        this.setData({
            [key]: item.value || "",
        });
    },
    onSearch() {},
    onDropClose() {
        this.initData();
    },

    getInitParams() {
        let status = this.$key2Name({
            type: this.data.taskStateValue + "",
            name: "state",
            list: this.data.taskStateList,
        });
        return {
            url: "task/list",
            data: {
                status,
                //全部为0，我创建的为1，我收到的为2
                taskKind: 2,
            },
        };
    },
    loginSuccess() {
        this.initData();
    },
});
